package com.example.app;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;
import android.widget.Button;
import android.widget.TextView;

public class novoAqui extends Activity {

    private int helper;

    @Override

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_novo_aqui);


        Bundle extras = getIntent().getExtras();
        this.helper = extras.getInt("helper");

        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment(helper))
                    .commit();
        }
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.novo_aqui, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     *
     */


    public static class PlaceholderFragment extends Fragment {

        private int helperId;
        public PlaceholderFragment(int helperId) {
            this.helperId = helperId;
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_novo_aqui, container, false);

            TextView meuTexto = (TextView)rootView.findViewById(R.id.help_text);
            switch (helperId){
                case 0:
                    getActivity().setTitle("E-SPORTS");
                    meuTexto.setText(R.string.eSportDescri);
                    break;
                    //meuTexto.setText(Integer.toString(helperId));
                case 1:
                    getActivity().setTitle("MOBA");
                    meuTexto.setText(R.string.mobaDesscri);
                    //meuTexto.setText(Integer.toString(helperId));
                    break;
                case 2:
                    getActivity().setTitle("RTS");
                    meuTexto.setText(R.string.rtsDesscri);
                    //meuTexto.setText(Integer.toString(helperId));
                    break;
                case 3:
                    getActivity().setTitle("FPS");
                    meuTexto.setText(R.string.fpsDesscri);
                    //meuTexto.setText(Integer.toString(helperId));
                    break;
                case 4:
                    getActivity().setTitle("FIGHTING");
                    meuTexto.setText(R.string.fightingDesscri);
                    //meuTexto.setText(Integer.toString(helperId));
                    break;
                default:
                    meuTexto.setText("ERRO!");
                    break;
            }


            Button closeBtn = (Button)rootView.findViewById(R.id.closeBtn);
            closeBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    getActivity().finish();
                }
            });

            return rootView;
        }
    }

}
